package lyx.tank.element
{
	import flash.display.BitmapData;
	import flash.display.Graphics;
	import flash.display.Sprite;
	import flash.geom.Matrix;
	
	import lyx.game.element.DynamicGameElement;
	import lyx.game.utils.Direction;

	
	public class Bullet extends DynamicGameElement
	{
		static public var BULLET_VIEW_DATA:BitmapData;
		
		public var face_style:int = 0x991122;
		
		public var shooter_type:String;
		
		public function Bullet(x:int,y:int,direction:int,owner_type:String)
		{
			super(x-10/2,y-10/2,direction);
			
			this.step_speed = 150;
			this.shooter_type = owner_type;
			
			updateViewContext();
		}
		
		override public function move(time:int):void
		{
			steps = 1;
			super.move(time);
		}
		
		override protected function outActiveAreaHandler():void
		{
			life = 0;
		}
		
		override protected function updateViewContext():void
		{
			if(BULLET_VIEW_DATA==null)
			{
				var graphics_face:Sprite = new Sprite();
				graphics_face.graphics.clear();
				graphics_face.graphics.beginFill(face_style);
				graphics_face.graphics.drawCircle(5,5,5);
				graphics_face.graphics.endFill();
				BULLET_VIEW_DATA = new BitmapData(10,10,true,0);
				BULLET_VIEW_DATA.draw(graphics_face);
			}
			
			view_data = BULLET_VIEW_DATA;
		}
	}
}